package org.itboys.mobile.dto;

import java.math.BigDecimal;

/**
 * 作者：jiangxiong
 * 日期：2017年5月8日
 * 描述：圣代_预支付（返回给前端的记过）_dto。
 */

public class TianJieWalletBlockDto extends MobileBaseDto{
    private BigDecimal baseAmount;//本金
    private BigDecimal ableAmount;//可用本金
    private BigDecimal blockNumber;//持币数量
    public TianJieWalletBlockDto() {

    }

    public TianJieWalletBlockDto(long id, String createTime, String createDate, BigDecimal baseAmount, BigDecimal ableAmount, BigDecimal blockNumber) {
        super(id, createTime, createDate);
        this.baseAmount = baseAmount;
        this.ableAmount = ableAmount;
        this.blockNumber = blockNumber;
    }

    public BigDecimal getBaseAmount() {
        return baseAmount;
    }

    public void setBaseAmount(BigDecimal baseAmount) {
        this.baseAmount = baseAmount;
    }

    public BigDecimal getAbleAmount() {
        return ableAmount;
    }

    public void setAbleAmount(BigDecimal ableAmount) {
        this.ableAmount = ableAmount;
    }

    public BigDecimal getBlockNumber() {
        return blockNumber;
    }

    public void setBlockNumber(BigDecimal blockNumber) {
        this.blockNumber = blockNumber;
    }

    /**
     * 可提现金额
     * @return
     */
    public BigDecimal getAbleCashAmount(){
        BigDecimal ableCashAmount=new BigDecimal("0");
        if(ableAmount!=null&&
                baseAmount!=null&&
                ableAmount.subtract(baseAmount).compareTo(new BigDecimal("0"))==1){
            ableCashAmount=ableAmount.subtract(baseAmount);
        }
        return ableCashAmount;
    }
    public String getBaseAmountStr(){
        BigDecimal tenThousand=new BigDecimal("10000");
        String baseAmountStr="";
        if(baseAmount.compareTo(tenThousand)==1){
            baseAmountStr=baseAmount.divide(tenThousand,2,BigDecimal.ROUND_HALF_UP).toString()+"万";
        }else{
            baseAmountStr=baseAmount.setScale(2,BigDecimal.ROUND_HALF_UP).toString();
        }
        return baseAmountStr;
    }
    public String getAbleAmountStr(){
        BigDecimal tenThousand=new BigDecimal("10000");
        String ableAmountStr="";
        if(ableAmount.compareTo(tenThousand)==1){
            ableAmountStr=ableAmount.divide(tenThousand,2,BigDecimal.ROUND_HALF_UP).toString()+"万";
        }else{
            ableAmountStr=ableAmount.setScale(2,BigDecimal.ROUND_HALF_UP).toString();
        }
        return ableAmountStr;
    }
    public String getAbleCashAmountStr() {
        BigDecimal ableCashAmount = new BigDecimal("0");
        if (ableAmount != null &&
                baseAmount != null &&
                ableAmount.subtract(baseAmount).compareTo(new BigDecimal("0")) == 1) {
            ableCashAmount = ableAmount.subtract(baseAmount);
        }
        BigDecimal tenThousand = new BigDecimal("10000");
        String ableCashAmountStr = "";
        if (ableCashAmount.compareTo(tenThousand) == 1) {
            ableCashAmountStr = ableCashAmount.divide(tenThousand, 2, BigDecimal.ROUND_HALF_UP).toString()+"万";
        } else {
            ableCashAmountStr = ableCashAmount.setScale(2, BigDecimal.ROUND_HALF_UP).toString();
        }
        return ableCashAmountStr;
    }
    public String getInfo(){
        return "字段说明：1，baseAmount:本金;2，ableAmount:可用本金，3，blockNumber:持币数量,4,ableCashAmount：可提现金额（提现模块使用此金额），4钱包中带Str字符串金额单位为：万";
    }
}
